package start;

import javax.swing.*;

import java.awt.*;
public class Splash{
	
	static JFrame frame;
	JProgressBar progress=new JProgressBar(0,100);
	JPanel pan=new JPanel();
	JLabel img=new JLabel();
	JLabel txt=new JLabel("load");
	MethImage meth=new MethImage();
	Thread thread;
	
	public Splash(){
		
		super();
		
		//cr�ation de la fen�tre de d�marrage
		frame=new JFrame();
		
		//cr�ation du label qui va contenir l'image
		ImageIcon ico=meth.createImageIcon("icon/splashlog.png", "oeil");
		img.setIcon(ico);
		
		
		/*//le texte load
		txt.setFont(new Font("anastasia", Font.BOLD+Font.ITALIC, 12));
		txt.setHorizontalTextPosition(JLabel.CENTER);
		txt.setForeground(Color.WHITE);*/
		
		//barre de progression
		//progress.setStringPainted(true);
		//progress.setBounds(new Rectangle(10,200,200,10));
		
		//panneau
		frame.setSize(534, 100);
		frame.getContentPane().add(BorderLayout.CENTER, pan);
		//pan.setBorder(BorderFactory.createLineBorder(Color.BLACK)); 
		pan.setBackground(Color.decode("#ffffff"));
		pan.add(img);
		//pan.add(progress);
		//pan.add(txt);
		
		//dimension et location de la fen�tre
		frame.setSize(ico.getIconWidth() , ico.getIconHeight());
		Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
		frame.setLocation(screen.width/2 - frame.getSize().width/2,screen.height/2 - frame.getSize().height/2); 
		
		//thread
		thread =new Thread(new Progression()); 
		thread.start();
		
		//mettre toujours la fen�tre en premier plan
		frame.setAlwaysOnTop(true);
		
		//enlever les d�corations de la fen�tre
		frame.setUndecorated(true);
		
		//emp�cher le redimensionnement de la fen�tre
		frame.setResizable(false);
		
		//rendre la fen�tre visible
		frame.setVisible(true);
		//frame.pack();
		
	}

	public class Progression implements Runnable{
		
		public Progression(){
			
		}

		public void run() {
			 for (int j = 1; j < 100; j++) {
				progress.setValue(j);
				try {
				
				Thread.sleep(30);
				//new EmploiTemps("jdbc:mysql://localhost/minipr","com.mysql.jdbc.Driver","root","");
				}
				catch(Exception e)
			    {
				e.printStackTrace();
				frame.dispose();//en cas d' erreur
			     }
				}
				
				frame.dispose();
			
		}
	}
}
		